package com.woniuxy.hystirx;

import com.woniuxy.api.RemoteProductServer;
import com.woniuxy.entity.Product;
import com.woniuxy.entity.utils.ResponseEntity;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * @Author: 马宇航
 * @Do: 统一全局熔断降级响应
 * @DateTime: 22/06/24/0024 下午 4:09
 * @Component: 成都蜗牛学苑
 **/
@Component
public class FallBackFactory implements FallbackFactory<RemoteProductServer> {
    @Override
    public RemoteProductServer create(Throwable throwable) {
        return new RemoteProductServer() {
            @Override
            public ResponseEntity findOneById(Integer id) {
                return ResponseEntity.TIMEOUT;
            }

            @Override
            public ResponseEntity addProduct(Product product) {
                return ResponseEntity.TIMEOUT;
            }

            @Override
            public ResponseEntity search1(Integer minimumInventory, Integer maxInventory) {
                return ResponseEntity.TIMEOUT;
            }

            @Override
            public ResponseEntity search2(Map<String, Object> map) {
                return ResponseEntity.TIMEOUT;
            }
        };
    }
}
